package com.innovativethinking.web.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.innovativethinking.domain.service.KanbanTweetService;
import com.innovativethinking.web.name.RequestAttributeName;


@SuppressWarnings("serial")
@Singleton
public class KanbanLifecycleServlet extends HttpServlet {
	
	@Inject private KanbanTweetService ktService = null;
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
		
		Long kanbanId = new Long(req.getParameter(RequestAttributeName.KANBAN_ID));
		
		String operation = req.getServletPath();
		
		String buffer = ktService.update(kanbanId, operation);
		
		req.setAttribute(RequestAttributeName.BUFFER, buffer);
		
		RequestDispatcher rd = req.getRequestDispatcher("/kanbantweet");
		
		rd.forward(req, resp);
	}	
}
